package com.dbh.alg.algorithm.hot100.哈希;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 董帮辉
 * @date 2025/7/12
 **/
public class Leetcode1_两数之和 {

    public int[] twoSum(int[] nums, int target) {
        int left = 0, right = nums.length - 1;
        int[] result = new int[2];
        while (left < right) {
            if (nums[left] + nums[right] == target) {
                result[0] = left + 1;
                result[1] = right + 1;
            } else if (nums[left] + nums[right] < target) {
                left++;
            } else {
                right--;
            }
        }
        return result;
    }

}
